import java.util.ArrayList;
import java.util.List;

class Subject {
    List<Observer> observers = new ArrayList<Observer>();

    public String State;

    public Subject(String state) {
        this.State = state;
    }

    public void add(Observer observer) {
        observers.add(observer);
    }

    public void remove(Observer observer) {
        observers.remove(observer);
    }

    public void push() {
        for (Observer observer : observers) {
            observer.update();
        }
    }
}

public abstract class Observer {
    public static void main(String[] args) {
        Subject sa = new Subject("SA");
        sa.add(new ObserverA(sa));
        sa.add(new ObserverB(sa));
        sa.push();
    }

    public Subject Subject;

    public Observer(Subject subject) {
        this.Subject = subject;
    }

    public abstract void update();
}

class ObserverA extends Observer {
    public ObserverA(Subject subject) {
        super(subject);
    }

    @Override
    public void update() {
        System.out.println(String.format("ObserverA get %s", Subject.State));
    }
}

class ObserverB extends Observer {
    public ObserverB(Subject subject) {
        super(subject);
    }

    @Override
    public void update() {
        System.out.println(String.format("ObserverB get %s", Subject.State));
    }
}